package com.xuzhao.utils;

import com.xuzhao.entity.Result;
import com.xuzhao.enums.ResultEnum;

/**
 * Created by xz on 2017/9/3.
 * 异常返回码处理工具类
 */
public class ResultUtil {
    /**
     * 成功
     * @param obj
     * @return
     */
    public static Result success(Object obj){
        Result result = new Result();
        result.setCode(ResultEnum.SUCCESS.getCode());
        result.setMsg(ResultEnum.SUCCESS.getMsg());
        result.setData(obj);
        return result;
    }


    /**
     * 失败了
     * @param code
     * @param msg
     * @return
     */
    public static Result eror(Integer code,String msg){
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
}
